class TFHGunAttach extends xWeaponAttachment;

var class<xEmitter>     MuzFlashClass;
var xEmitter            mMuzFlash3rd;

var class<xEmitter>     mShellCaseEmitterClass;
var xEmitter            mShellCaseEmitter;
var() vector            mShellEmitterOffset;


function Destroyed()
{
    if (mMuzFlash3rd != None)
        mMuzFlash3rd.Destroy();

    if (mShellCaseEmitter != None)
        mShellCaseEmitter.Destroy();

	Super.Destroyed();
}

simulated event ThirdPersonEffects()
{
    local rotator r;

    if ( (Level.NetMode == NM_DedicatedServer) || (Instigator == None)
		|| ((Level.TimeSeconds - LastRenderTime > 0.2) && (PlayerController(Instigator.Controller) == None)) )
        return;
	WeaponLight();

    if ( FlashCount > 0 )
	{
        if (mMuzFlash3rd == None)
        {
            mMuzFlash3rd = Spawn(MuzFlashClass);
            AttachToBone(mMuzFlash3rd, 'tip');
        }
        if (mMuzFlash3rd != None)
        {
            mMuzFlash3rd.Trigger(self, None);
            r.Roll = Rand(65536);
            SetBoneRotation('Bone Flash', r, 0, 1.f);
        }

        if ( (mShellCaseEmitter == None) && (Level.DetailMode != DM_Low) )
        {
            mShellCaseEmitter = Spawn(mShellCaseEmitterClass);
            if ( mShellCaseEmitter != None )
				AttachToBone(mShellCaseEmitter, 'shell');
        }
        if (mShellCaseEmitter != None)
            mShellCaseEmitter.mStartParticles++;
    }
    else
    {
        GotoState('');
    }

    Super.ThirdPersonEffects();
}

defaultproperties
{
     MuzFlashClass=Class'XEffects.MinigunMuzFlash3rd'
     bHeavy=True
     bRapidFire=True
     bAltRapidFire=True
     LightType=LT_Pulse
     LightEffect=LE_NonIncidence
     LightHue=30
     LightSaturation=150
     LightBrightness=150.000000
     LightRadius=4.000000
     LightPeriod=3
     Mesh=SkeletalMesh'Weapons.Minigun_3rd'
     DrawScale3D=(Y=1.700000,Z=1.700000)
     Skins(0)=Texture'TFMedia.Gunner.HGTex0'
}
